{include file="common/_header"}
{include file="common/_header1"}

<body class="layui-anim layui-anim-up">
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">报表管理</a>
            <a>
              <cite>商铺订单管理</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>

<div class="x-body">

    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <div class="layui-input-inline">
                <div class="layui-unselect layui-form-select utype" style="display:inline-block;">
                    <select name="utype" lay-filter="utype" class="utype">
                        <option value="">全部</option>
                        <option value="2" {$data.get.utype == 2?'selected':''}>会员</option>
                        <option value="3" {$data.get.utype == 3?'selected':''}>普通用户</option>
                    </select>
                </div>
                <button class="layui-btn"  lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
            </div>

        </form>
    </div>

    <table id="tables" class="layui-table">
        <thead>
        <tr>
<!--            <th>ID</th>-->
            <th>微信名称</th>
            <th>最后登录时间</th>
            <th>登录ip</th>
            <th>用户头像</th>
            <th></th>
        </tr>
        </thead>
        <tbody>
        {volist name="data.data" id="vo"}
        <tr class="table_tr">
<!--            <td>{$vo.user_id}</td>-->
            <td>{$vo.nick_name}</td>
            <td>{if !empty($vo.lastlogin)}{$vo.lastlogin|date="Y-m-d H:i:s"}{/if}</td>
            <td>{$vo.loginip}</td>
            <td><img src="{$vo.avatar}"></td>
            <td>
                <ul class="nav navbar-nav" style=" height: 40px; line-height: 10px;">
                    <li class="dropdown" style="height: 100%;">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" style=" height: 100%; line-height: 5px;">
                            操作
                            <b class="caret"></b>
                        </a>
                        <ul class="dropdown-menu">
                            {if $vo.is_sales == 1}
                                <li><a title="升级" onclick="upgrade('{$vo.user_id}')" href="javascript:;">升级团长</a></li>
                            {/if}
                        </ul>
                    </li>
                </ul>
            </td>
        </tr>
        {/volist}
        </tbody>
    </table>
    <div class="page_all">
        {$page|raw}
    </div>
</div>
<script>

    /*升级团长*/
    function upgrade(id) {
        layer.confirm('您确定要升级该用户为团长吗?', {btn: ['确定', '取消'], title: "提示"}, function () {
            $.ajax({
                url: 'upgradesales',
                data:{
                    'id':id,
                },
                type: 'post',
                dataType: 'json',
                success: function (data) {
                    layer.msg(data.msg, {
                        icon: 6,
                        time: 500,
                    }, function () {
                        window.location.reload();
                    })
                }
            })
        });
    }

    $(function () {
        // 表格选中行的同时选中单选框
        $("#tables tr:gt(0)").click(function () {
            $(this).find(":radio").prop("checked", true);
        });

    });

    //js放到table下，才能检测到tr数组
    var trs = document.getElementById("tables").getElementsByTagName("tr");
    $(function () {
        for (var i = 0; i < trs.length; i++) {
            trs[i].onmousedown = function () {
                mousedownclick(this);
            }
        }
    });

    function mousedownclick(obj) {
        for (var j = 0; j < trs.length; j++) {
            if (trs[j] == obj) {
                if (trs[0] != obj) {
                    trs[j].style.background = '#D0E9C6';
                    // 启用新增和编辑按钮
                    $("#edits").removeAttr("disabled");//启用按钮
                    $('#edits').removeClass('layui-disabled');
                }
            } else {
                trs[j].style.background = '';
            }
        }
    }
</script>
</body>

{include file="common/_bottom"}